Skip to content

api-maintenance · core: Begin and Transact take *sql.TxOptions - #23

Merged
JaimeStill merged 6 commits into
mainfrom
core
Nov 11, 2026
Merged

JaimeStill merged 6 commits into
mainfrom
core

Conversation

@JaimeStill

Copy link
Copy Markdown
Contributor

api-maintenance · task 1/7 · core

Summary

go-core reactor.New(src, fn, reactor.Options{CancelAfter: reactor.CancelWithin(drain)})
event.NewRecorder(sink, source, event.Options{Clock, IDs})
sqlate db.Begin(ctx, &sql.TxOptions{Isolation: sql.LevelSerializable, ReadOnly: true})
db.Transact(ctx, fn, nil) // nil = default transaction
removed reactor.Option, reactor.CancelAfter, event.Option, event.Clock, event.IDs,
sqlate.TxOption, sqlate.Isolation, sqlate.ReadOnly — no aliases

Core changes

  1. reactor.New(src, fn, opts ...Option) → reactor.New(src, fn, opts Options)
    CancelWithin(drain) Option → CancelWithin(drain) time.Duration (half the drain)
    why: construction-and-execution — one trailing options struct; zero value keeps today's default
  2. event.NewRecorder(sink, source, opts ...Option) → NewRecorder(sink, source, opts Options)
    why: same rule; each nil field keeps its own default (time.Now in UTC, UUID v7)
  3. sqlate DB.Begin(ctx, opts ...TxOption) → DB.Begin(ctx, opts *sql.TxOptions)
    DB.Transact / Transact gain a required trailing *sql.TxOptions; Beginner.Begin matches DB.Begin
    why: adopt the standard library's options type instead of our own (existing solution)
  4. sqlate brought current: go 1.27.4, golangci-lint 2.15.0, mise-action v5.2.7,
    create-gh-release-action v1.12.0, postgres on pgx v5.13.0
  5. Docs: READMEs, doc.go, sqlate's guides show only the new forms; changelogs go-core v0.12.0
    and sqlate v0.7.0 with "Migrating from" sections, postgres v0.7.0, sqlint v0.4.0; both
    STANDARDS.md point to construction-and-execution

Evidence

go-core mise run check ✓ all packages, race tests, 0 lint issues
mise run currency ✓ exit 0
sqlate mise run check ✓ base, postgres, sqlint (each GOWORK=off), 0 lint issues, sqlint ok
mise run currency ✓ exit 0
go vet -tags integration ./... (postgres, sqlint; workspace on) ✓
mise run integration ✓ postgres 13.4s against a live database
spec review: behaviors 1–10, 12, 13 hold; 11 deferred to release by the brief
(go doc -short ./reactor ./event and sqlate: old exports absent)

Decided without you

  1. Took pgx v5.13.0, not the brief's v5.12.0: released today, minor, nothing to adapt;
    currency can't exit 0 otherwise
  2. sqlate's go.mod files stay go 1.27, no toolchain line (repo tracks only the minor)
  3. event.Options applies defaults per field, as the old options did
  4. Transact's *sql.TxOptions is required, not variadic; callers pass nil
  5. "Migrating from" sections only where something is removed (go-core, sqlate); postgres and
    sqlint carry one Breaking line for the sqlate v0.7.0 requirement
  6. Changelog entries dated 2026-11-11 (each repo's convention); redated at tag time if later
  7. Standards-reviewer: renamed a test that claimed to cover CancelWithin but no longer did;
    rewrapped long doc lines. Editor: tightened four doc comments and one guide sentence

Merge danger

one-way door for the tags · go-core v0.12.0; sqlate v0.7.0, postgres/v0.7.0, sqlint/v0.4.0
two-way for code and docs (merge by PR before tagging)
blast radius: every consumer of reactor, event, and sqlate's transactions — later tasks of
this goal migrate them; nothing else moves until then
release order: go-core merge → ci → tag v0.12.0; sqlate merge → ci → tag v0.7.0; then a
core-fix PR moves postgres and sqlint onto sqlate v0.7.0 (behavior 11), ci, then tag
postgres/v0.7.0 and sqlint/v0.4.0

Needs you

(none)

- mise.toml: go 1.27.2 -> 1.27.4, golangci-lint 2.14.0 -> 2.15.0
- workflows: jdx/mise-action v5.1.2 -> v5.2.7,
  taiki-e/create-gh-release-action v1.11.0 -> v1.12.0
- postgres: pgx/v5 v5.11.0 -> v5.13.0 (v5.13.0 was released after the
  brief named v5.12.0; taken so currency reports nothing behind, with no
  code to adapt), sqlate v0.6.0 -> v0.6.1; tidy moved puddle/v2, x/sync,
  x/text indirects
- sqlint: sqlate v0.5.0 -> v0.6.1

go directives stay at `go 1.27` with no toolchain line, matching the
upgrade task's convention of tracking only the Go minor. golangci-lint
2.15.0 flags nothing. No API changes.
DB.Begin(ctx, opts *sql.TxOptions) passes opts to the pool's BeginTx as
given: nil opens a default transaction, and a non-nil value's isolation
level and read-only flag reach the driver unchanged. DB.Transact and the
package-level Transact take a trailing *sql.TxOptions (required, nil for
the default) and pass it to Begin; their commit, rollback-join, and
panic handling are unchanged. Beginner's Begin has DB.Begin's signature,
so *DB and any type embedding it still satisfy it.

TxOption, Isolation, and ReadOnly are removed with no deprecated aliases.

Callers in the base module move to the new form: query's returning
fallback passes nil to Transact, and the tests pass nil or an explicit
*sql.TxOptions. The tests over sqltest's recorder (which already records
each begin's driver.TxOptions) show nil reaching the driver as default
options and a non-nil value's Isolation and ReadOnly reaching it as given,
through Begin, DB.Transact, and Transact on an embedding Beginner.

postgres's integration-tagged returning_live_test.go still implements the
old Beginner signature; it builds only with the integration tag in
workspace mode, outside the check, and moves in a later slice.
…-module changelogs

postgres's returning_live_test.go (integration tag) implements Begin(ctx,
*sql.TxOptions) on its counting session and passes nil as Transact's new
trailing argument. No other integration-tagged or sub-module code used the
removed TxOption API; neither sub-module's exported API did.

Changelogs: postgres v0.7.0 and sqlint v0.4.0, dated 2026-11-11, each
marking the sqlate v0.7.0 requirement as Breaking (as the earlier
requirement moves to a behavior-breaking base were), with a migrating note
for callers of Begin/Transact, and stating the module's own API is
unchanged. Compare links added.

go.mod still requires sqlate v0.6.1 until v0.7.0 is tagged, so the
GOWORK=off integration build of postgres fails on returning_live_test.go
until release preparation moves the requirement; the check (untagged)
passes. Verified: go vet -tags integration in workspace mode for postgres
and sqlint, and mise run integration against the compose PostgreSQL.
…ruction-and-execution

- docs/features.md: Transactions describe DB.Begin(ctx, opts), DB.Transact
  and Transact with the trailing *sql.TxOptions (nil = default
  transaction), and Beginner.Begin's DB.Begin signature; TxOption,
  Isolation, and ReadOnly are gone from the guide.
- docs/quick-start.md: the two Transact calls pass nil; the Replace note
  says what the last argument is.
- CHANGELOG.md: v0.7.0 (2026-11-11) with the signature changes under
  Changed and the removals under Removed, all marked Breaking, a
  "Migrating from v0.6.x" section with old-to-new code (Begin options,
  Transact's trailing argument, a Beginner implementer's Begin), and the
  compare links. The base changelog has never recorded toolchain or CI
  upgrades and slice 1 changed no base go directive or dependency, so the
  toolchain upgrade is not listed. The migrating heading follows go-core's
  "### Migrating from vX" form, since this file had none before.
- STANDARDS.md: points to go-elemental's construction-and-execution
  principle in the same form as its other pointers.

README.md and doc.go already show only the new forms (doc.go since the
API change); no example_test.go exists.
…paragraph

Applies context-architecture: the doc.go-side comment and the guide read
at their wrap width after the *sql.TxOptions change left them ragged.
@JaimeStill
JaimeStill merged commit e7c9ea9 into main Nov 11, 2026
1 check passed
@JaimeStill
JaimeStill deleted the core branch November 11, 2026 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant